function Cache() {
	this.sampleArr=[]
	this.fyArr=[]
	this.bg1Arr=[]
	this.bg2Arr=[]
	this.noticeArr=[]
	this.letterArr=[]
	this.xcjl = Xcjl()
	this.qczp = Qczp()

	this.getData = function () {
		var picArr = []
		this.qczp.forEach(item =>{
			var file = item.file
			if(file){
				var f = new File([file],item.title + '-' + file.name,{type:file.type})
				picArr.push(f)
			}
		})

		return {
			sampleArr: this.sampleArr,
			fyArr: this.fyArr,
			bg1Arr: this.bg1Arr,
			bg2Arr: this.bg2Arr,
			noticeArr: this.noticeArr,
			letterArr: this.letterArr,
			xcjl: this.xcjl,
			picArr: picArr
		}
	}

	this.reset = function () {
        this.sampleArr=[]
        this.fyArr=[]
        this.bg1Arr=[]
        this.bg2Arr=[]
        this.noticeArr=[]
        this.letterArr=[]
        this.xcjl = Xcjl()
        this.qczp = Qczp()
    }

	/**
	 * 获取样品数量
	 */
	this.getYpSize = function(){
		return this.sampleArr.length;
	}
	
	/**
	 * 添加样品
	 */
	this.addYp = function(){
		this.sampleArr.push(Sample())
		this.fyArr.push(Fy())
		this.bg1Arr.push(Bg1())
		this.bg2Arr.push(Bg2())
		this.noticeArr.push(Notice())
		this.letterArr.push(Letter())

		this.xcjl.descList.forEach(item =>{
			item.push('')
		})
	}
	
	/**
	 * 删除样品
	 * @param {Object} idx
	 */
	this.delYp = function(idx){
		this.sampleArr.splice(idx,1)
		this.fyArr.splice(idx,1)
		this.bg1Arr.splice(idx,1)
		this.bg2Arr.splice(idx,1)
		this.noticeArr.splice(idx,1)
		this.letterArr.splice(idx,1)
		this.xcjl.descList.forEach(item =>{
			item.splice(idx+1,1)
		})
		// TODO 关联页面数据处理
	}
	
	/**
	 * 获取扦样
	 * @param {Object} idx
	 */
	this.getItemData = function(idx,type){
		var obj={}
		switch (type){
			case 'sample':
				obj = this.sampleArr[idx]
				break;
			case 'fy':
				obj = this.fyArr[idx]
				break;
			case 'bg1':
				obj = this.bg1Arr[idx]
				break;
			case 'bg2':
				obj = this.bg2Arr[idx]
				break;
			case 'notice':
				obj = this.noticeArr[idx]
				break;
			case 'letter':
				obj = this.letterArr[idx]
				break;
		}
		return obj;
	}

	this.setItemData = function(obj,idx,type){
		switch (type){
			case 'sample':
				this.sampleArr[idx] = obj
				break;
			case 'fy':
				this.fyArr[idx] = obj
				break;
			case 'bg1':
				this.bg1Arr[idx] = obj
				break;
			case 'bg2':
				this.bg2Arr[idx] = obj
				break;
			case 'notice':
				this.noticeArr[idx] = obj
				break;
			case 'letter':
				this.letterArr[idx] = obj
				break;
		}
	}

	/**
	 * 获取扦样
	 * @param {Object} idx
	 */
	this.getSample = function(idx){
		return this.sampleArr[idx]
	}

	/**
	 * 设置扦样
	 * @param {Object} sample
	 * @param {Object} idx
	 */
	this.setSample = function(sample,idx){
		this.sampleArr[idx] = sample
	}
	
	/**
	 * 设置封页
	 * @param {Object} sample
	 * @param {Object} idx
	 */
	this.setFy = function(fy,idx){
		this.fyArr[idx] = fy
	}
	
	/**
	 * 设置Bg1
	 * @param {Object} sample
	 * @param {Object} idx
	 */
	this.setBg1 = function(bg1,idx){
		this.bg1Arr[idx] = bg1
	}
	
	/**
	 * 设置Bg2
	 * @param {Object} sample
	 * @param {Object} idx
	 */
	this.setBg2 = function(bg2,idx){
		this.bg2Arr[idx] = bg2
	}
	
	/**
	 * 设置注意事项
	 * @param {Object} sample
	 * @param {Object} idx
	 */
	this.setNotice = function(notice,idx){
		this.noticeArr[idx] = notice
	}
	
	/**
	 * 设置确认函
	 * @param {Object} sample
	 * @param {Object} idx
	 */
	this.setLetter = function(letter,idx){
		this.letterArr[idx] = letter
	}

	/**
	 * 设置确认函
	 * @param {Object} sample
	 * @param {Object} idx
	 */
	this.getXcjl = function(){
		return this.xcjl
	}

	/**
	 * 扦样
	 */

	function Sample(){
		var obj = {
			sampleNo:'',
			companyType:'企业',
			companyName:'',
			lealPerson:'',
			address:'',
			postcode:'',
			contacts:'',
			tel:'',
			producer:'',
			postcode2:'',
			address2:'',
			tel2:'',
			cropType:'',
            cropName:'',
			seedType:'',
			bzActive:true,
			bzLabel:'包装标注检测日期',
			bzDate:'',
			expiration:'',
			lotNum:'',
			packingSize:'',
			sealed:true,
			count:'',
			weight:'',
			gmo:true,
			sampleSite:'',
			sampleType:'',
			registeredMark:'',
			chemical:true,
			testItem:[],
			testMethod:'',
			criterion:'',
			companyName2:'广州市农作物种子质量检验中心',
			address3:'广州市南沙区东涌镇市南路663号',
			tel3:'020-39004105',
			date:'',
			si:'',
			gr:'',
			purity:'',
			water:'',
            chemicalMsg:'',
            remark:''
		}

		return obj;
	}


	/**
	 * 封页
	 */
	function Fy(){
		var obj = {
			cropType:'',
			cropName:'',
			companyName:'',
			bgNo:'',
			testCategory:'',
		}

		return obj;
	}

	/**
	 * 报告1
	 */
	function Bg1(){
		var obj = {
			author:'',
			sampleNo:'',
			companyName:'',
			producer:'',
			cropType:'',
			cropName:'',
			bzLabel:'',
			bzDate:'',
			expiration:'',
			lotNum:'',
			count:'',
			weight:'',
			sampleSite:'',
			registeredMark:'',
			testItem : '',
			testMethod:'',
			criterion:'',
			permeability:'',
			instrument:'',
			samplingPerson:'',
			date:'',
			qualityIndex:'',
			testCate:'',
			evn:'符合实验要求',
			sampleStatus:'封缄完好',
			ypNo : 'DJ',
			bgNo : 'BJ',
			conclusion:'依据《农作物种子检验规程》（GB/T 3543.1~7-1995），对样品的&1&进行检验；'+
			'根据&2&，判定该批种子所检项目的检测指标均符合要求。',
			remark:'无',
            year:'',
            month:' 月 日'
		}

		return obj;
	}

	/**
	 * 报告2
	 */
	function Bg2(){
		var obj = {
			cropType:'',
			ypNo: 'GZJ2105001',
			bgNo:'BJ',
			si:'',
			gr:'',
			water:'',
			deviation1:'',
			deviation2:'',
			deviation3:'无',
			result1:'',
			result2:'',
			result3:'合格',
			param1:'',
			param2:'',
			param3:'',
			param4:'',
			param5:'',
			param6:'',
			param7:'',
			param8:'',
			param9:'',
			param10:'',
			param11:'',
			param12:'',
			param13:'',
			param14:'',
            param15:'无',
            param16:'破碎种子、秸秆、沙粒、石块',
		}
		
		return obj;
	}

	/**
	 * 注意事项
	 */
	function Notice(){
		var obj = {
			address:'广州市南沙区东涌镇市南路663号',
			tel:'020-39004105',
			postcode:'511453',
			desc : [
				'1、 报告无“检验检测专用章”和检验单位公章无效。',
				'2、 复制报告未重新加盖“检验检测专用章”和检验单位公章无效。',
				'3、 报告无制表、审核、批准人签章无效。',
				'4、 报告涂改、骑缝章不完整无效。',
				'5、 送样检验仅对来样负责。',
				'6、 对报告有异议，应于收到报告十五日之内向检验单位提出，逾期不予受理。',
				'7、 未经本中心同意，该报告不得用于商业性宣传。'
			]
		}

		return obj;
	}

	/**
	 * 确认函
	 */
	function Letter(){
		var obj = {
			sampleNo:'',
			companyName:'',
			producer:'',
			cropType:'',
			cropName:'',
			bzDate:'',
			lotNum:'',
			qualityIndex:'',
			principal:'--',
			seedType:'',
			origin:'',
			packingSize:'',
			address2:'',
			tel2:'',
			other:'',
            seedNo:'',
            no:'',
            addr:'广州市南沙区东涌镇市南路663号',
            concats:'肖婉钰',
            tel:'020-39004105'
		}

		return obj;
	}


	function Xcjl() {
		var obj = {
			companyName: '',
			date: '',
			operator: [],
			recorder: [],
			sampleSite: '',
			companyType: '',
			contacts: '',
			tel: '',
			cropName: '',
			cropType: '',
			sampleNos: '',
            line1:'1. 扦样单位扦样人员向被抽查单位提供了《广州市2021年农作物种子质量监督抽查通知书》（编号：GZ-001），出示了种子检验员证 等工作证件；介绍了本次抽查任务的性质和扦样方法、检验项目、检验依据、判定依据等内容，以及被抽查单位配合监督抽查的权利和义务。',
			descList: [
				["品种"],
				["生产商"],
				["主要销往"],
				["繁种总量(kg)"],
				["繁种时间"],
				["繁种地点"],
				["繁种价(元/kg)"],
				["繁种联系人"],
				["种子生产经营许可证编号"],
				["检疫证明编号"],
				["已加工包装(kg)"],
				["入库时间"],
				["包装规格"],
				["包装标注检测时间"],
				["质量保质期"],
				["已销售(kg)"],
				["销售价(元/kg)"],
				["样品库存(kg)"],
				["本次抽取(kg)"],
				["现库存(kg)"]
			]
		}
		return obj
	}

    function Qczp (){
		return [
			{title:'扦样现场', file:''},
			{title:'扦样品种', file:''},
			{title:'营业执照', file:''},
			{title:'扦样品种', file:''},
			{title:'进货票据', file:''},
			{title:'检疫证书', file:''},
			{title:'农作物种子生产经营备案表', file:''},
			{title:'种子销售授权委托书', file:''},
		]
	}

	this.createQczp = function () {
        return Qczp();
    }
}

window.cache = new Cache()

